<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    [(${sakaiHtmlHead})]
  </head>
  <body onload="setMainFrameHeight('Mainmercuryx710');setFocus(focus_path);" class="Mrphs-container Mrphs-sakai-plus">
    <div class="portletBody">
        <h1><span th="#{plus.tool.tenant.title}">Tenant:<span>
            <span th:text="${tenant.title}">Sakai</span>
            <span th:if="${tenant.isDraft}" th:text="#{plus.tool.tenant.draft}">(draft)</span>
        </h1>
        <p><a th:href="@{/}" th:text="#{plus.tool.all.tenants}" class="btn btn-secondary">All Tenants</a></p>
        <div th:if="${flashError}" class="sak-banner-error">
            <p th:text="${flashError}">Placeholder</p>
        </div>
        <p>
        (<a href="https://github.com/sakaiproject/sakai/blob/master/plus/README.md#sakaiplus-tenants" target="_blank" th:text="#{plus.tenant.documentation.url}">SakaiPlus Tenant Documentation</a>)
        </p>
        <form class="form-horizontal" action="#" th:action="@{/tenant}" method="post" th:object="${tenant}">
        <input th:if="${doUpdate}" type="hidden" th:field="*{id}" />
        <div id="title-group" class="form-group">
          <label for="plus-title" class="form-control-label required" th:text="#{plus.tool.title}">Value</label>
          <div>
            <input type="text" class="form-control" id="plus-title" th:value="${tenant.title}" th:field="*{title}" required />
          </div>
        </div>
        <div id="issuer-group" class="form-group">
          <label for="issuer" class="form-control-label required" th:text="#{plus.tool.issuer}">Value</label>
          <div>
            <input type="text" class="form-control" id="issuer" th:value="${tenant.issuer}" th:field="*{issuer}" pattern="https?://[^\s\/]+(?:\/[^\/\s]+)*$" th:attr="title=#{plus.tenant.issuer.error.slash}" required aria-describedby="issuer-input-error" />
            <span id="issuer-input-error" class="sr-only"></span>
          </div>
          <div th:text="#{plus.tool.issuer.detail}">
              This is different for each LMS, but it is usually a URL like "https://plus.sakalms.org" - with no trailing slash.
              Sometimes this will be the domain where the LMS is hosted.  For some cloud-hosted providers, they use one issuer
              across all customers.  This field is required.
          </div>
        </div>
        <div id="trustemail-group" class="form-group form-switch">
          <div>
            <input type="hidden" class="form-control" id="trustemail-boolean" th:value="${tenant.trustEmail}" th:field="*{trustEmail}" />
            <input th:if="${tenant.trustEmail}" checked class="form-check-input" type="checkbox" id="trustemail" role="switch" onclick="booleanClick(event);"/>
            <input th:if="${!tenant.trustEmail}" class="form-check-input" type="checkbox" id="trustemail" role="switch" onclick="booleanClick(event);"/>
            <label for="trustemail" class="form-control-label" th:text="#{plus.tool.trustemail}">Value</label>
          </div>
        </div>
        <p th:text="#{plus.tool.trustemail.detail}">
            plus.tool.trustemail.detail
        </p>
        <div id="timezone-group" class="form-group">
          <label for="timezone" class="form-control-label" th:text="#{plus.tool.timezone}">Value</label>
          <div>
            <input type="text" class="form-control" id="timezone" th:value="${tenant.timeZone}" th:field="*{timeZone}" />
          </div>
          <div th:text="#{plus.tool.timezone.detail}">
              This is the timezone for the controlling LMS.  SakaiPlus will shift due dates into this timezone before creating
              or updating line items.
          </div>
        </div>
        <div id="oidcregistrationlock-group" class="form-group">
          <label for="oidcregistrationlock" class="form-control-label" th:text="#{plus.tool.oidcregistrationlock}">Value</label>
          <div>
            <input type="text" class="form-control" id="oidcregistrationlock" th:value="${tenant.oidcRegistrationLock}" th:field="*{oidcRegistrationLock}" />
          </div>
          <div th:text="#{plus.tool.oidcregistrationlock.detail}">
              You set this field to "unlock" LTI Dynamic Registration for this tenant.  It should only be set while performing dynamic registration
              and should be cleared after dynamic registration is complete.
          </div>
        </div>
        <div id="clientid-group" class="form-group">
          <label for="clientid" class="form-control-label" th:text="#{plus.tool.clientid}">Value</label>
          <div>
            <input type="text" class="form-control" id="clientid" th:value="${tenant.clientId}" th:field="*{clientId}" />
          </div>
        </div>
        <div id="deploymentid-group" class="form-group">
          <label for="deploymentid" class="form-control-label" th:text="#{plus.tool.deploymentid}">Value</label>
          <div>
            <input type="text" class="form-control" id="deploymentid" th:value="${tenant.deploymentId}" th:field="*{deploymentId}" />
          </div>
        </div>
        <div id="sitetemplate-group" class="form-group">
          <label for="sitetemplate" class="form-control-label" th:text="#{plus.tool.sitetemplate}">Value</label>
          <div>
              <input type="text" class="form-control" id="sitetemplate" th:value="${tenant.siteTemplate}" th:field="*{siteTemplate}" />
          </div>
          <div th:text="#{plus.tool.sitetemplate.detail}">
              plus.tool.sitetemplate.detail
          </div>
        </div>
        <div id="realmtemplate-group" class="form-group">
          <label for="realmtemplate" class="form-control-label" th:text="#{plus.tool.realmtemplate}">Value</label>
          <div>
              <input type="text" class="form-control" id="realmtemplate" th:value="${tenant.realmTemplate}" th:field="*{realmTemplate}" />
          </div>
          <div th:text="#{plus.tool.realmtemplate.detail}">
              plus.tool.realmtemplate.detail
          </div>
        </div>
        <div id="inboundrolemap-group" class="form-group">
          <label for="inboundrolemap" class="form-control-label" th:text="#{plus.tool.inboundrolemap}">Value</label>
          <div>
              <input type="text" class="form-control" id="inboundrolemap" th:value="${tenant.inboundRoleMap}" th:field="*{inboundRoleMap}" />
          </div>
          <div th:text="#{plus.tool.inboundrolemap.detail}">
              This field is a colon-separated list of Sakai tool ids which will be forced to always open
              in a new window. The "sakai.site" is always launched in a new window.  This is typically left blank.
          </div>
        </div>
        <p>
        (<a href="https://github.com/sakaiproject/sakai/blob/master/lti/docs/LTIROLES.md" target="_blank" th:text="#{plus.tool.inboundrolemap.url}">SakaiPlus Tenant Documentation</a>)
        </p>
        <div id="verbose-group" class="form-group form-switch">
          <div>
            <input type="hidden" class="form-control" id="verbose-boolean" th:value="${tenant.verbose}" th:field="*{verbose}" />
            <input th:if="${tenant.verbose}" checked class="form-check-input" type="checkbox" id="verbose" role="switch" onclick="booleanClick(event);"/>
            <input th:if="${!tenant.verbose}" class="form-check-input" type="checkbox" id="verbose" role="switch" onclick="booleanClick(event);"/>
            <label for="verbose" class="form-control-label" th:text="#{plus.tool.verbose}">Value</label>
          </div>
        </div>
        <p th:text="#{plus.tool.verbose.detail}">
            plus.tool.verbose.detail
        </p>
        <p th:text="#{plus.tool.oidc.detail}">
            plus.tool.oidc.detail
        </p>
        <div id="oidckeyset-group" class="form-group">
          <label for="oidckeyset" class="form-control-label" th:text="#{plus.tool.oidckeyset}">Value</label>
          <div>
            <input type="text" class="form-control" id="oidckeyset" th:value="${tenant.oidcKeySet}" th:field="*{oidcKeySet}" />
          </div>
        </div>
        <div id="oidcauth-group" class="form-group">
          <label for="oidcauth" class="form-control-label" th:text="#{plus.tool.oidcauth}">Value</label>
          <div>
            <input type="text" class="form-control" id="oidcauth" th:value="${tenant.oidcAuth}" th:field="*{oidcAuth}" />
          </div>
        </div>
        <div id="oidctoken-group" class="form-group">
          <label for="oidctoken" class="form-control-label" th:text="#{plus.tool.oidctoken}">Value</label>
          <div>
            <input type="text" class="form-control" id="oidctoken" th:value="${tenant.oidcToken}" th:field="*{oidcToken}" />
          </div>
        </div>
        <div id="oidcaudience-group" class="form-group">
          <label for="oidcaudience" class="form-control-label" th:text="#{plus.tool.oidcaudience}">Value</label>
          <div>
            <input type="text" class="form-control" id="oidcaudience" th:value="${tenant.oidcAudience}" th:field="*{oidcAudience}" />
          </div>
        </div>
        <div id="edit-group" class="form-group">
            <button type="submit" th:if="${doUpdate}" th:text="#{plus.tool.update}" class="btn btn-primary">Update Tenant</button>
            <button type="submit" th:if="${!doUpdate}" th:text="#{plus.tool.add}" class="btn btn-primary">Add Tenant</button>
            <a th:href="@{/}" th:text="#{plus.tool.cancel}" class="btn btn-default">Cancel</a>
        </div>
        </form>
    </div>
<script>
function booleanClick(ev) {
    let id = ev.target.id;
    let checked = ev.target.checked;
    let inp = document.getElementById(id+'-boolean');
    inp.value = checked ? 'true' : 'false';
}
</script>
  </body>
</html>
